package com.htudata.live.service.impl;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

import com.htudata.live.pojo.vo.AlarmsCurrentVO;
import com.htudata.live.service.AlarmService;
import org.springframework.stereotype.Service;

@Service
public class AlarmServiceImpl implements AlarmService {

  public List<AlarmsCurrentVO> getVOList(String... args) {
    String[] problem1 = { "17:19:51", "区域自动站", "数据入库服务器", "id.auto.db.in.h", "小时入库量220M", "1", "5m 24s" };
    String[] problem2 = { "17:19:01", "区域自动站", "数据入库服务器", "id.auto.db.in.d", "日入库量8.5G", "0", "1h 28m 30m" };
    String[] problem3 = { "17:14:48", "区域自动站", "数据入库服务器", "id.auto.db.in.tc", "入库平均耗时10s", "1", "8m 3s" };
    String[] problem4 = { "17:04:43", "区域自动站", "消息中间件服务器", "id.auto.mdl.dep.r", "积压数据量(字节)占比30%", "0", "58s" };
    String[] problem5 = { "17:04:43", "雷达基数据", "SOD", "id.sod.f.fmt", "双偏振雷达文件接收数50个", "1", "11m 23s" };
    List<String[]> alarmsCurrentList = (List)new ArrayList<>();
    alarmsCurrentList.add(problem1);
    alarmsCurrentList.add(problem2);
    alarmsCurrentList.add(problem3);
    alarmsCurrentList.add(problem4);
    alarmsCurrentList.add(problem5);
    List<AlarmsCurrentVO> alarmsCurrentVOList = new ArrayList<>();
    for (int i = 0; i < alarmsCurrentList.size(); i++) {
      AlarmsCurrentVO alarmsCurrentVO = new AlarmsCurrentVO();
      alarmsCurrentVO.setAlarmId(i);
      alarmsCurrentVO.setStartTime(((String[])alarmsCurrentList.get(i))[0]);
      alarmsCurrentVO.setFlowName(((String[])alarmsCurrentList.get(i))[1]);
      alarmsCurrentVO.setHostName(((String[])alarmsCurrentList.get(i))[2]);
      alarmsCurrentVO.setItemId(((String[])alarmsCurrentList.get(i))[3]);
      alarmsCurrentVO.setProblem(((String[])alarmsCurrentList.get(i))[4]);
      alarmsCurrentVO.setStatus(Integer.valueOf(((String[])alarmsCurrentList.get(i))[5]).intValue());
      alarmsCurrentVO.setDuration(((String[])alarmsCurrentList.get(i))[6]);
      alarmsCurrentVO.setLevel(1);
      alarmsCurrentVO.setFlowId(1);
      String[] colorString = { "#FF0000", "#FFFF00", "#00FF00" };
      alarmsCurrentVO.setColor(colorString[(new Random()).nextInt(3)]);
      alarmsCurrentVOList.add(alarmsCurrentVO);
    } 
    return alarmsCurrentVOList;
  }
}
